package cn.tedu.apiday04;

import java.io.*;

public class WriterActiong {//字符流写出

    public static void main(String[] args) throws IOException {
        method();//FileWriter写出
        method1();//BufferedWriter写出    高效 char数组cb  高效


    }

    private static void method1() throws IOException {
        Writer w = new BufferedWriter(new FileWriter("E:\\360downloads\\520.txt",true));//追加
        Writer w1= new BufferedWriter(new FileWriter("E:\\360downloads\\520.txt"));//覆盖
        w.write(98);
        //释放资源，还可以把数据从流里刷到磁盘中
        w.close();
        //w .flush(); 只把数据从流里刷到磁盘中

    }

    private static void method() throws IOException {
        Writer w = new FileWriter("E:\\360downloads\\520.txt");//String类型构造方法，覆盖
        Writer w1 = new FileWriter(new File("E:\\360downloads\\520.txt"));//File类型构造方法。覆盖
        Writer w2 = new FileWriter("E:\\360downloads\\520.txt",true);//String类型构造方法，追加
        Writer w3 = new FileWriter(new File("E:\\360downloads\\520.txt"),true);//File类型构造方法。追加
        w.write(98);
        w.close();
    }
}
